<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>echarts</title>
    <style>
      .chart-container1,
      .chart-container {
        width: 800px;
        height: 400px;
      }
    </style>
  </head>
  <body>
    <div class="chart-container"></div>
    <div class="chart-container1"></div>
    <script src="./echarts.min.js"></script>
    <script>
      function randomData(num, min = 10, max = 100) {
        const data = [];
        for (let i = 0; i < num; i++) {
          data.push(Math.round(Math.random() * (max - min) + min));
        }
        return data;
      }

      const myEcharts = echarts.init(
        document.querySelector(".chart-container")
      );
      const option = {
        title: {
          text: "折线图",
        },
        xAxis: {
          data: [
            "一月",
            "二月",
            "三月",
            "四月",
            "五月",
            "六月",
            "七月",
            "八月",
            "九月",
            "十月",
            "十一月",
            "十二月",
          ],
        },
        yAxis: {},
        series: {
          type: "line",
          data: randomData(12),
        },
      };
      myEcharts.setOption(option);

      const myEcharts1 = echarts.init(
        document.querySelector(".chart-container1")
      );
      const option1 = {
        title: {
          text: "柱形图",
        },
        xAxis: {
          data: [
            "一月",
            "二月",
            "三月",
            "四月",
            "五月",
            "六月",
            "七月",
            "八月",
            "九月",
            "十月",
            "十一月",
            "十二月",
          ],
        },
        yAxis: {},
        series: {
          type: "bar",
          data: randomData(12),
        },
      };
      myEcharts1.setOption(option1);
    </script>
  </body>
</html>
